<?php
session_start();
if(!isset($_SESSION['email'])) {
header('location:index.php'); }
else { $email = $_SESSION['email']; }
require_once("koneksi.php");


if (isset($_POST['updatenama_anggota']))
$updatenama_anggota = $_POST['updatenama_anggota'];
if (isset($_POST['updateusername']))
$updateusername = $_POST['updateusername'];
if (isset($_POST['updateemail']))
$updateemail = $_POST['updateemail'];
if (isset($_POST['updatepassword']))
$updatepassword = $_POST['updatepassword'];
if (isset($_POST['updatekontak']))
$updatekontak = $_POST['updatekontak'];

if (isset($_FILES['foto_profile']['tmp_name']))
$lokasi_file = $_FILES['foto_profile']['tmp_name'];
if (isset($_FILES['foto_profile']['type']))
$tipe_file   = $_FILES['foto_profile']['type'];
if (isset($_FILES['foto_profile']['name']))
$nama_file   = $_FILES['foto_profile']['name'];
$direktori   = "images/image_profile/$nama_file";

move_uploaded_file($lokasi_file,$direktori);
$update = mysql_query("UPDATE anggota SET nama_anggota='$updatenama_anggota', username='$updateusername', email='$updateemail', password='$updatepassword', kontak='$updatekontak', foto_profile='$direktori' WHERE email='$email'");
if($update || $simpan) {
header ('location:index.php?page=editprofile');}

else {
echo "Proses Gagal!";
}
?>